import request from '@/utils/request'
import { SkuInfoData, SkuResponseData } from './type'
// 枚举SKU相关的接口地址
enum API {
  // 获取已有的商品的接口地址
  SKU_URL = '/admin/product/list/',
  // 商品上架的接口地址
  SALE_URL = '/admin/product/onSale/',
  // 商品下架的接口地址
  CANCEL_SALE_URL = '/admin/product/cancelSale/',
  // 获取商品详细信息的接口地址
  SKU_INFO_URL = '/admin/product/getSkuInfo/',
  // 删除指定SKU的接口地址
  DELETE_SKU_URL = '/admin/product/deleteSku/',
}

// 获取商品SKU的接口方法
export const reqSkuList = (page: number, limit: number) =>
  request.get<any, SkuResponseData>(API.SKU_URL + `${page}/${limit}`)
// 已有商品上架的接口方法
export const reqSaleSpu = (skuId: number) =>
  request.get<any, any>(API.SALE_URL + skuId)
// 已有商品下架的接口方法
export const reqCancelSale = (skuId: number) =>
  request.get<any, any>(API.CANCEL_SALE_URL + skuId)
// 获取指定SKU的详细信息的接口方法
export const reqSkuInfo = (skuId: number) =>
  request.get<any, SkuInfoData>(API.SKU_INFO_URL + skuId)
// 删除指定SKU的接口方法
export const reqDeleteSku = (skuId: number) =>
  request.delete<any, any>(API.DELETE_SKU_URL + skuId)
